package com.newtouch.cq.security.config;

import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Getter
@Configuration
@ConfigurationProperties("mcc.oauth2")
public class MccOauth2Properties {

    public static boolean disableSession = true; //是否禁用session

    public static String tokenHeader = "Authorization"; //tokenHeader

    public static String tokenStart = "Bearer "; //tokenStart

    public static boolean authentication = false; //是否开启权限验证 默认不开启

    /**
     * the urls for permitAll.
     */
    public static List<String> urlPermitAll = new ArrayList<>();

    public void setDisableSession(boolean disableSession) {
        this.disableSession = disableSession;
    }

    public void setTokenHeader(String tokenHeader) {
        this.tokenHeader = tokenHeader;
    }

    public void setTokenStart(String tokenStart) {
        this.tokenStart = tokenStart;
    }

    public void setUrlPermitAll(List<String> urlPermitAll) {
        this.urlPermitAll = urlPermitAll;
    }

    public void setAuthentication(boolean authentication) {
        MccOauth2Properties.authentication = authentication;
    }

    /**
     * accessTokenValiditySeconds, default: 30 days.
     */
    private int accessTokenValiditySeconds = 60 * 60 * 24 * 30;

    /**
     * refreshTokenValiditySeconds, default: 12 hours.
     */
    private int refreshTokenValiditySeconds = 60 * 60 * 12;

    private boolean signleOnline = false;


    //    /**
//     * The key store properties for locating common key in common Java Key Store (common file in common format
//     * defined and understood by the JVM).
//     */
//    private KeyStore keyStore = new KeyStore();
//
//    @Data
//    @ConfigurationProperties("encrypt")
//    public static class KeyStore {
//
//        /**
//         * Location of the key store file, e.g. classpath:/keystore.jks.
//         */
//        private Resource location;
//
//        /**
//         * Password that locks the keystore.
//         */
//        private String password;
//
//        /**
//         * Alias for common key in the store.
//         */
//        private String alias;
//
//        /**
//         * Secret protecting the key (defaults to the same as the password).
//         */
//        private String secret;
//
//    }
}
